'''
Author: lololo 2246223018@qq.com
Date: 2024-01-05 14:58:12
LastEditors: lololo 2246223018@qq.com
LastEditTime: 2024-01-05 15:05:23
FilePath: /python/novelRolesMap/demo2.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''

import jieba.posseg as posseg
import pandas

# 打开文件
with open('53643.txt', 'r') as f:
    data = f.read()
words = []
for word,flag in posseg.cut(data):
    if flag == 'nr':
        words.append(word)

with open('name_dict.txt', 'a+') as f:
    # 获取前100个高频人名
    res = pandas.Series(words).value_counts()[0:100]
    res = list(res.index)
    for i in res:
        f.write(str(i)+'\n')

# 然后建立人物有向关系 见demo3
